﻿<div class="ph-tabs">
    <ul>
        <li class="k-state-active">导入成绩</li>
    </ul>

    <div>
        <div class="GeneralEdit">
            <ul>
                <li>
                    <label>档案：</label>
                    <select id="selArchive" style="width: 400px"></select>
                </li>
                <li>
                    <label>请选择年级：</label>
                    <select id="selGrade"></select>
                </li>
                <li>
                    <label></label>
                    <a href="#" target="_blank" class="k-button" id="template">点击下载体测成绩模板</a>
                </li>
                <li>
                    <label>上传文件：</label>
                    <ul class="upfile k-block">
                        <li>
                            <input type="file" id="fileAux" name="fileAux" data-fid="" /></li>
                        <li>
                            <h4 id="fuAuxMsg"></h4>
                        </li>
                    </ul>
                </li>
                <li id="lip">
                    <label>完成进度：</label>
                    <div id="progressbar"></div>
                </li>
                <li>
                    <div style="color: red; font-size: 12px; padding-left: 150px">提示：目前暂时只支持Excel2003版,如果有项目免试，请在相应的成绩中填入字母M</div>
                </li>
                <li class="editButtons">
                    <button id="btnImport" class="k-button"><span class="k-icon k-i-tick"></span><span>开始导入</span></button>
                </li>
            </ul>
        </div>
    </div>
</div>

<script class="init">
    LocatedMenu("体测数据", "导入成绩");

    $("#selArchive").kendoDropDownList({
        dataTextField: "Title",
        dataValueField: "Guid",
        dataSource: Whale.dataSource({
            url: "/Achievements/Archive/Gets",
            getParameters: function () {
                return {
                    aType: 2,
                    expired: false
                }
            }
        }),
        dataBound: function (e) {
            if (this.dataSource.data().length == 0) {
                this.setDataSource(new kendo.data.DataSource({
                    data: [{ Title: "暂无档案", Guid: "" }]
                }));
            }
        }
    });

    $("#selGrade").kendoDropDownList({
        dataTextField: "GradeName",
        dataValueField: "Code",
        dataSource: Whale.dataSource({
            url: "/School/Config/GetGrades",
            getParameters: function () {
                return {
                    schType:"@PH.Web.Global.WebContext.CurrentSchool.SchType"
                }
            }
        }),
        dataBound: function (e) {
            var item = this.dataItem(e.itemIndex);
            $("#template").attr("href", "/Achievements/Mark/DownTemplate/" + item.Code);
        },
        change: function (e) {
            var item = this.dataItem(e.itemIndex);
            $("#template").attr("href", "/Achievements/Mark/DownTemplate/" + item.Code);
        }
    });

    var pb = $("#progressbar").kendoProgressBar({
        type: "percent",
        min: 0,
        max: 100
    }).data("kendoProgressBar");
    $("#lip").hide();
</script>

<script class="import_mark">
    $(function () {
        $("#btnImport").click(function (e) {
            pb.value(0);
            $("#btnImport").hide();
            $("#lip").show();

            var values = {
                fGuid: $("#fileAux").attr("data-fid"),
                sGuid: "@PH.Web.Global.WebContext.CurrentSchool.Guid",
                aGuid: $("#selArchive").data("kendoDropDownList").value()
            };

            Whale.Remote.Operation({
                url: "/Achivevments/Mark/ImportMark",
                parameters: values,
                success: function (result) {
                    wndGeneralInformation.content("学生成绩导入成功。").open();
                    $("#btnImport").show();
                    $("#lip").hide();
                },
                error: function (msg) {
                    wndGeneralInformation.content(msg).open();
                    $("#btnImport").show();
                    $("#lip").hide();
                }
            });

            setTimeout(function () {
                GetFileProgress(values.fGuid, pb);
            }, 3000);
        });
    });
</script>
